In [1]:
import pandas as pd
import plotly.express as px
# 1) Load data and quick preview
marketing_summary = pd.read_csv("/Users/gillianmondero/Downloads/marketing_summary.csv")
marketing_summary["date"] = pd.to_datetime(marketing_summary["date"])
marketing_summary["conversion_rate"] = (
marketing_summary["new_customers"] / marketing_summary["users_active"]
).fillna(0)
print("Data preview:")
print(marketing_summary.head(), "\n")
Data preview:
date users_active total_sales new_customers report_generated \
0 2023-06-01 179 81287.31 9 2023-06-01 16:00
1 2023-06-02 67 74771.99 5 2023-06-02 16:00
2 2023-06-03 369 84809.74 11 2023-06-03 16:00
3 2023-06-04 94 61212.30 3 2023-06-04 16:00
4 2023-06-05 402 80911.49 10 2023-06-05 16:00
col_6 col_7 col_8 col_9 col_10 ... col_42 col_43 col_44 col_45 \
0 North 519.37 NaN North 987.06 ... West NaN 756.0 South
1 East NaN 75.0 South 916.36 ... West 457.14 NaN West
2 NaN 512.79 2643.0 East 420.43 ... South 161.89 3339.0 South
3 South NaN 1264.0 North 16.13 ... North 661.14 NaN NaN
4 North 965.78 1108.0 South 147.12 ... West 222.50 394.0 South
col_46 col_47 col_48 col_49 col_50 conversion_rate
0 81.97 NaN East NaN NaN 0.050279
1 482.41 1327.0 East NaN 4506.0 0.074627
2 18.71 3484.0 East 753.98 463.0 0.029810
3 NaN 4517.0 North NaN 2294.0 0.031915
4 498.87 3364.0 NaN 678.05 NaN 0.024876
[5 rows x 51 columns]
In [2]:
# 2) Basic KPI totals
tot_sales = marketing_summary["total_sales"].sum()
tot_active = marketing_summary["users_active"].sum()
tot_newcust = marketing_summary["new_customers"].sum()
avg_conv = marketing_summary["conversion_rate"].mean()
print("KPI numbers:")
print(f"Total Sales : ₱{tot_sales:,.2f}")
print(f"Active Users : {tot_active:,}")
print(f"New Customers : {tot_newcust:,}")
print(f"Avg Conversion : {avg_conv:.2%}\n")
KPI numbers: Total Sales : ₱5,767,580.45 Active Users : 27,331 New Customers : 765 Avg Conversion : 3.75%
In [5]:
# 3) Visualisations + save to JPG
fig1 = px.line(marketing_summary, x="date", y="total_sales",
title="Total Sales Over Time")
fig1.show()
fig1.write_image("total_sales_over_time.jpg", format="jpg", scale=2)
fig2 = px.line(marketing_summary, x="date", y="users_active",
title="Daily Active Users")
fig2.show()
fig2.write_image("daily_active_users.jpg", format="jpg", scale=2)
fig3 = px.bar(marketing_summary, x="date", y="new_customers",
title="New Customers Per Day")
fig3.show()
fig3.write_image("new_customers_per_day.jpg", format="jpg", scale=2)
fig4 = px.line(marketing_summary, x="date", y="conversion_rate",
title="Conversion Rate Over Time")
fig4.show()
fig4.write_image("conversion_rate_over_time.jpg", format="jpg", scale=2)
In [ ]: